﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyHocPhi.BLL;
using QuanLyHocPhi.Model;

namespace QuanLyHocPhi.GUI.DuLieu
{
    public partial class FormTaoMoiHocKy : Form
    {
        public Model.HocKy InsertedHocKy { get; private set; }


        public FormTaoMoiHocKy()
        {
            InitializeComponent();
            nudNamHoc_BD.Value = DateTime.Now.Year;
            nudNamHoc_KT.Value = DateTime.Now.Year + 1;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                string namHoc = Convert.ToInt32(nudNamHoc_BD.Value).ToString() + "-" + Convert.ToInt32(nudNamHoc_KT.Value).ToString();
                int hocKy = Convert.ToInt32(nudHocKy.Value);
                InsertedHocKy = BizHocKy.AddHocKy(namHoc, hocKy);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception exc)
            {
                DialogUtils.ShowError(exc.Message);
            }
        }

        private void nudNamHoc_BD_ValueChanged(object sender, EventArgs e)
        {
            if (nudNamHoc_BD.Focused)
                nudNamHoc_KT.Value = nudNamHoc_BD.Value + 1;
        }
    }
}
